// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function singleton<T extends { new(...args: any[]): {}, prototype: any }>(className : T) : T & { instance: T["prototype"] } {
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
	let instance : any;
	const proxy = new Proxy(className, {
		construct (_, args) {
			if (!instance) {
				instance = new className(...args);
			};
			return instance;
		},
	});
	
	className.prototype.contructor = proxy;
	return proxy as T & { instance: T["prototype"] };
}